<?php

namespace app\common\util;

use think\facade\Log;

class LogHelper
{
    public static function log($content, $level = "debug", $format = "json", $method = "write")
    {
        $logStr = getNow() . " : ";
        if (is_array($content) || is_object($content)) {
            if ($format == "json") {
                $logStr .= json_encode($content, JSON_UNESCAPED_UNICODE);
            } else {
                $logStr .= print_r($content, true);
            }
        } else {
            $logStr .= print_r($content, true);
        }
        if ($method == "write") {
            Log::write($logStr, $level);
        } else {
            Log::record($logStr, $level);
        }
    }
}